createResultProvider

@ApiStatus.Experimental
abstract fun <T : Any> createResultProvider(fallback: Supplier<T>, clazz: KClass<T>): ResultProvider<T>

Creates a result provider that will return values of the given type from a config. This provider will inspect the registered config matching to the scope provided, utilizing the fallback instead if a valid scope isn't provided.

For an overview of scope, see the translation wiki page.

You can also supply args via the scope string by appending them with a ? like mod_id.config_id.settingName?arg?arg2. See the wiki for details on how this is or can be utilized.

Results are cached per scope provided. The cache is cleared automatically at the end of data pack reload.

Return

ResultProvider to supply results based on passed scopes. This should be created once per use-case (static, companion object, etc), otherwise caching won't be effective.

Author

fzzyhmstrs

Since

0.5.3

Parameters

T

non-null provider type. Needs to be a type that can actually be provided by a config

fallback

Supplier<T> - supplies a fallback value if the scope provided isn't valid. This fallback will be cached against any invalid scope, and an error logged, rather than an exception being thrown.

clazz

KClass<T> - class type to provide. Scopes provided can point to either a direct instance of the type, or validatedField<T>. So Boolean and ValidatedBoolean are both valid targets for a Boolean provider.


@ApiStatus.Experimental
abstract fun <T : Any> createResultProvider(fallback: Supplier<T>, drillFunction: ResultProviderSupplier<T>): ResultProvider<T>

Creates a result provider that will return values of the given type from a config. This provider will inspect the registered config matching to the scope provided, utilizing the fallback instead if a valid scope isn't provided.

For an overview of scope, see the translation wiki page.

You can also supply args via the scope string by appending them with a ? like mod_id.config_id.settingName?arg?arg2. See the wiki for details on how this is or can be utilized.

Results are cached per scope provided. The cache is cleared automatically at the end of data pack reload.

Return

ResultProvider to supply results based on passed scopes. This should be created once per use-case (static, companion object, etc), otherwise caching won't be effective.

Author

fzzyhmstrs

Since

0.5.3

Parameters

T

non-null provider type. Needs to be a type that can actually be provided by a config

fallback

Supplier<T> - supplies a fallback value if the scope provided isn't valid. This fallback will be cached against any invalid scope, and an error logged, rather than an exception being thrown.

drillFunction

ResultProviderSupplier - a custom creator of Suppliers for creating scoped results.